
#include <stdint.h>
#include "lrb.h"

static void lrb_cb(int lrb, lite_rb_evt_e evt) {
    switch(evt)
    {
        case LITE_RB_EVT_EMPTY:
            lrb_log("LITE_RB_EVT_EMPTY");
            break;
        case LITE_RB_EVT_FULL:
            lrb_log("LITE_RB_EVT_FULL");
            break;
        case LITE_RB_EVT_HIGH_MARK:
            lrb_log("LITE_RB_EVT_HIGH_MARK");
            break;
        case LITE_RB_EVT_LOW_MARK:
            lrb_log("LITE_RB_EVT_LOW_MARK");
            break;
    }
}

int main(void) {
    int lrb = lite_rb_init(10, 8, 4, lrb_cb);
    int write_len = 0;
    int read_len = 0;
    uint8_t r_data[20] = {0};

    write_len = lite_rb_write(lrb, "0123456789abc", 6);
    lrb_log("write len: %d", write_len);

    read_len = lite_rb_read(lrb, r_data, 3);
    lrb_log("read len: [%d] %s", read_len, r_data);

    write_len = lite_rb_write(lrb, "abcdefghi", 10);
    lrb_log("write len: %d", write_len);

    lrb_log("buffer is full: %d", lite_rb_is_full(lrb));

    read_len = lite_rb_read(lrb, r_data+3, 8);
    lrb_log("read len: [%d] %s", read_len, r_data);

    read_len = lite_rb_read(lrb, r_data+11, 8);
    lrb_log("read len: [%d] %s", read_len, r_data);

    lrb_log("buffer is empty: %d", lite_rb_is_empty(lrb));

    lite_rb_deinit(lrb);

    return 0;
}
